package engine.logic
{
	import com.greensock.TweenLite;
	
	import engine.GameData;
	import engine.display.newAttack.AttackLogic;
	import engine.flag.GameDefine;
	import engine.flag.ObjType;
	import engine.scene.SceneChangeManager;
	import engine.scene.SceneManager;
	import engine.scene.player.BasePlayerModel;
	import engine.scene.player.NpcModel;
	
	import flash.display.MovieClip;
	import flash.geom.Point;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;

	/**
	 * 导航
	 * @author gufan
	 */	
	public class ArrowGuideLogic
	{
		private static var self:ArrowGuideLogic;
		
		private var guideArrow:MovieClip;
		
		public var showGuideDis:int;
		private var guideArrowX:int;
		private var guideArrowY:int;
		
		private var arrowWidth:int;
		
		public function ArrowGuideLogic()
		{
			init();
		}
		
		public static function getInstance():ArrowGuideLogic
		{
			if(self	==	null)
			{
				self	=	new ArrowGuideLogic();
			}
			return self;
		}
		
		private function init():void
		{
			guideArrow	=	ResManager.newResClass("custSkin_184") as MovieClip;
			StageInfo.effectSpace.addChild(guideArrow);
			arrowWidth	=	guideArrow.width;
			guideArrow.visible	=	false;
			
			showGuideDis	=	int(StaticIni.getIniVar("GuideArrowDistance","dis"));
			guideArrowX		=	int(StaticIni.getIniVar("GuideArrowDistance","x"));
			guideArrowY		=	int(StaticIni.getIniVar("GuideArrowDistance","y"));
		}
		
		public function changeSize():void
		{
			if(guideArrow == null) return;
			
			var gameWidth : int = SceneChangeManager.getGameWidth();
			var xPoint : int;
			xPoint	=	gameWidth - arrowWidth - (gameWidth - StageInfo.rootW) * .5 - 400;
			
			guideArrow.x	=	xPoint + guideArrowX;
			guideArrow.y	=	guideArrowY;
			
//			TweenLite.to(guideArrow, .5, {x:xPoint});
		}
		
		/*public function checkShowState(playerArr:Array):void
		{
			if( AttackLogic.getInstance().fighting || GameData.SceneType == GameDefine.SceneType_Normal || !SceneManager.getInstance().norSceneView.visible 
				|| GameData.Role == null || GameData.Role.playerObj == null || GameData.Role.playerObj.GetPropertiesEx( "CanFight" ) == 1 )
			{
				hideArrow();
				return;
			}
			
			var player : BasePlayerModel;
			
			if( GameData.SceneType == GameDefine.SceneType_CS || GameData.SceneType == GameDefine.SceneType_WorldBossScene )
			{
				for each( player in playerArr )
				{
					if( player is NpcModel && player.playerObj.Type == ObjType.NPC && player.visible )
					{
						var dis : int = Point.distance( GameData.Role.point, player.point );
						if(dis >= showGuideDis)
						{
							showArrow();
						}
						else
						{
							hideArrow();
						}
					}
				}
			}
		}*/
		
		public function showArrow():void
		{
			guideArrow.visible	=	true;
			changeSize();
			guideArrow.play();
		}
		
		public function hideArrow():void
		{
			if(guideArrow)
			{
				guideArrow.stop();
				guideArrow.visible	=	false;
			}
		}		
		
	}
}